package com.wwj.mapper;

import com.github.pagehelper.Page;
import com.wwj.annotation.AutoFill;
import com.wwj.annotation.enumeration.OperationType;
import com.wwj.pojo.dto.CheckPageQueryDTO;
import com.wwj.pojo.entity.Check;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CheckMapper {

    @Insert("INSERT INTO `check`(name,description,price,status,create_time, update_time, create_user, update_user)" +
            "VALUES " +
            "(#{name},#{description},#{price},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser}) ")
    @AutoFill(value = OperationType.INSERT)
    //新增体检项目
    void insertCheck(Check check);

    //体检项目分页查询
    Page<Check> pageQuery(CheckPageQueryDTO checkPageQueryDTO);

    //更新体检项目
    void update(Check check);

    //根据id查询体检项目
    @Select("select * from `check` where id=#{id}")
    Check selectById(Long id);


    List<Check> selectByIds(List<Long> ids);
    //删除体检项目
    @Delete("delete from `check` where id=#{id}")
    void deleteById(Long id);

    //根据id查询status状态
    @Select("select status from `check` where id=#{id}")
    Integer statusById(Long id);

    //查询启用检查项
    @Select("select * from `check` where status = 1")
    List<Check> list();
}
